<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>
<%@page import="org.hibernate.HibernateException"%>
<%@page import="org.hibernate.Query"%>
<%@page import="org.hibernate.Session"%>
<%@page import="kickboxing.controller.NewsyManager"%>
<%@page import="kickboxing.model.Newsy"%>
<%@page import="kickboxing.util.HibernateUtil"%>
<%@page import="kickboxing.model.Uzytkownik"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
	<%
	Uzytkownik user = (Uzytkownik)session.getAttribute("user");
	if(user != null){
		if(user.getPrawa() == 'a')
		{
	%>


<script type="text/javascript">
function textArea()
{
	alert(myTextArea1.value); 
}
</script>
<style type="text/css">

#news {
  
color: white;
margin-left: 20px;
margin-right: 20px;
margin-bottom: 200px;
padding-top: 20px;
}
</style>
	<%
	request.setCharacterEncoding("UTF-8");
 	Session sessionHIBER = HibernateUtil.getSessionFactory().openSession();
    sessionHIBER.beginTransaction();
    Query q = sessionHIBER.createQuery("from Newsy n where n.id_newsu="+request.getParameter("id")+"");
    @SuppressWarnings("unchecked")
    List<Newsy> lista = q.list();

    %>
<script type="text/javascript">
textArea();
</script>
    <form action="../../NewsyEdycjaAction" method="post">
    	<input type="hidden" name="id_newsu" value="<%= lista.iterator().next().getId_newsu() %>">
		Temat: <input type="text" name="temat" value="<%= lista.iterator().next().getTemat() %>" /> <br>
		Tresc: <br>
		<textarea rows="15" cols="50" name="tresc" id="myTextArea1"><%= lista.iterator().next().getTresc().trim() %></textarea> <br>
		Data: <input type="text" name="data" value="<%= lista.iterator().next().getData() %>" /> <br>
		<input type="submit" value="edytuj" />
	</form>
    
    <%
    sessionHIBER.getTransaction().commit();
    %>
    
    
    
    
    
    
    
    
    	<%
		
			}
			}
		else{
		response.sendError(404,"Gladiator: brak uprawnien");
			}
	%>